# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=gst-plugins-good

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.3.1
pkgrel=1
pkgdesc="GStreamer Multimedia Framework Base Plugins (mingw-w64)"
arch=('any')
url="http://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
            "${MINGW_PACKAGE_PREFIX}-pkg-config"
            "${MINGW_PACKAGE_PREFIX}-gstreamer"
            "gtk-doc"
            "${MINGW_PACKAGE_PREFIX}-python2"
            "${MINGW_PACKAGE_PREFIX}-speex"
            )
depends=("${MINGW_PACKAGE_PREFIX}-cairo"
        "${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
        "${MINGW_PACKAGE_PREFIX}-gst-plugins-base"
        "${MINGW_PACKAGE_PREFIX}-libcaca"
        "${MINGW_PACKAGE_PREFIX}-libsoup"
        "${MINGW_PACKAGE_PREFIX}-libvpx"
        "${MINGW_PACKAGE_PREFIX}-taglib"
        "${MINGW_PACKAGE_PREFIX}-wavpack"
        )
options=(!libtool strip staticlibs)
source=(${url}/src/${_realname}/${_realname}-${pkgver}.tar.xz
        0001-fix-X-detection.mingw.patch
        0002-fix-test-running.mingw.patch)
md5sums=('24eae4c670c1d5baedd199e9abaa25ff'
         '89b320a3a5d5585801eef1b8e0489483'
         'b4ff5991217a2544fa84aae471057299')

prepare() {
  cd ${srcdir}/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/0001-fix-X-detection.mingw.patch
  patch -p1 -i ${srcdir}/0002-fix-test-running.mingw.patch
  
  NOCONFIGURE=1 ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  cp -r "${srcdir}/${_realname}-${pkgver}" "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --disable-static \
    --enable-shared \
    --enable-silent-rules \
    --enable-experimental \
    --disable-gtk-doc
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make -j1 DESTDIR="$pkgdir" install
  find "${pkgdir}${MINGW_PREFIX}" -name '*.def' -o -name '*.exp' | xargs -rtl1 rm
  rm -f ${pkgdir}${MINGW_PREFIX}/lib/gstreamer*/*.a
}
